
preavg=3000
premin=2700
money=40000

rangenum=50
addmoneyratio=1.5

tempnum=preavg
addcount=(preavg-premin)/rangenum
addcount+=1
addvalue=[];
initvalue=1;
sumcount=0;
for i in range(int(addcount)):
    addvalue.append(initvalue);
    sumcount+=initvalue;
    initvalue*=addmoneyratio;
avgmoney=money/sumcount
print("初始加仓金额："+str(round(avgmoney,2)) ,
      "加仓占比：1/"+str(round(sumcount)),
      "\n共计加仓金额："+ str(money)
      )
arrdianwei=[]
arraddmoney=[]
arrzhanbi=[]
for i in range(int(addcount)):
    arrdianwei.append(tempnum)
    arraddmoney.append(addvalue[i]*avgmoney)
    print('%s点 \t ￥ %s \t 占比 %s%%' %(tempnum,round(addvalue[i]*avgmoney),round(addvalue[i]/sumcount*100,2)) )
    # print(tempnum,round(addvalue[i]*avgmoney),round(addvalue[i]/sumcount,2)) 
    tempnum-=rangenum

# import pandas as pd
# df = pd.DataFrame({'加仓点位':arrdianwei, '加仓金额':arraddmoney,'加仓占比':addvalue})
# print (df)